From ab8d94d195ef456c04db7f21e106647941eb338e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 26 Jun 2011 21:28:37 -0400 Subject: [PATCH] Convert GailArrow to GtkArrowAccessible --- gtk/a11y/Makefile.am | 4 +- gtk/a11y/gail.c | 3 - gtk/a11y/gailarrow.c | 121 ---------------------------------- gtk/a11y/gailarrow.h | 53 --------------- gtk/a11y/gtkarrowaccessible.c | 93 ++++++++++++++++++++++++++ gtk/a11y/gtkarrowaccessible.h | 53 +++++++++++++++ gtk/gtkarrow.c | 4 ++ 7 files changed, 152 insertions(+), 179 deletions(-) delete mode 100644 gtk/a11y/gailarrow.c delete mode 100644 gtk/a11y/gailarrow.h create mode 100644 gtk/a11y/gtkarrowaccessible.c create mode 100644 gtk/a11y/gtkarrowaccessible.h diff --git a/gtk/a11y/Makefile.am b/gtk/a11y/Makefile.am index ca2181d15c..8674a264fd 100644 --- a/gtk/a11y/Makefile.am +++ b/gtk/a11y/Makefile.am @@ -6,7 +6,7 @@ gail_c_sources = \ gail-private-macros.h \ gail.c \ gailadjustment.c \ - gailarrow.c \ + gtkarrowaccessible.c \ gailbooleancell.c \ gailbox.c \ gailbutton.c \ @@ -60,7 +60,7 @@ libgailincludedir=$(includedir)/gail-3.0/gail gail_private_h_sources = \ gailadjustment.h \ - gailarrow.h \ + gtkarrowaccessible.h \ gailbooleancell.h \ gailbox.h \ gailbutton.h \ diff --git a/gtk/a11y/gail.c b/gtk/a11y/gail.c index b9e25f6ce9..31fd181f51 100644 --- a/gtk/a11y/gail.c +++ b/gtk/a11y/gail.c @@ -24,7 +24,6 @@ #include #include "gailadjustment.h" -#include "gailarrow.h" #include "gailbooleancell.h" #include "gailbox.h" #include "gailbutton.h" @@ -128,7 +127,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_PROGRESS_BAR, GailProgressBar, gail_progress_b GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW) GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_FRAME, GailFrame, gail_frame, GTK_TYPE_FRAME) GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RADIO_BUTTON, GailRadioButton, gail_radio_button, GTK_TYPE_RADIO_BUTTON) -GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_ARROW, GailArrow, gail_arrow, GTK_TYPE_ARROW) GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SEPARATOR, GailSeparator, gail_separator, GTK_TYPE_SEPARATOR) GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_BOX, GailBox, gail_box, GTK_TYPE_BOX) GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW) @@ -905,7 +903,6 @@ gail_accessibility_module_init (void) GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_PIXBUF, gail_image_cell); GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER, gail_renderer_cell); GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_BUTTON, gail_radio_button); - GAIL_WIDGET_SET_FACTORY (GTK_TYPE_ARROW, gail_arrow); GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SEPARATOR, gail_separator); GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BOX, gail_box); GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window); diff --git a/gtk/a11y/gailarrow.c b/gtk/a11y/gailarrow.c deleted file mode 100644 index 9253d84769..0000000000 --- a/gtk/a11y/gailarrow.c +++ /dev/null @@ -1,121 +0,0 @@ -/* GAIL - The GNOME Accessibility Implementation Library - * Copyright 2001 Sun Microsystems Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include "gailarrow.h" - -static void gail_arrow_class_init (GailArrowClass *klass); -static void gail_arrow_init (GailArrow *arrow); -static void gail_arrow_initialize (AtkObject *accessible, - gpointer data); - -/* AtkImage */ -static void atk_image_interface_init (AtkImageIface *iface); -static const gchar* gail_arrow_get_image_description - (AtkImage *obj); -static gboolean gail_arrow_set_image_description - (AtkImage *obj, - const gchar *description); -static void gail_arrow_finalize (GObject *object); - -G_DEFINE_TYPE_WITH_CODE (GailArrow, gail_arrow, GAIL_TYPE_WIDGET, - G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)) - -static void -gail_arrow_class_init (GailArrowClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); - - atk_object_class->initialize = gail_arrow_initialize; - - gobject_class->finalize = gail_arrow_finalize; -} - -static void -gail_arrow_init (GailArrow *arrow) -{ - arrow->image_description = NULL; -} - -static void -gail_arrow_initialize (AtkObject *accessible, - gpointer data) -{ - ATK_OBJECT_CLASS (gail_arrow_parent_class)->initialize (accessible, data); - - accessible->role = ATK_ROLE_ICON; -} - -static void -atk_image_interface_init (AtkImageIface *iface) -{ - iface->get_image_description = gail_arrow_get_image_description; - iface->set_image_description = gail_arrow_set_image_description; -} - -static const gchar* -gail_arrow_get_image_description (AtkImage *obj) -{ - GailArrow* arrow; - - g_return_val_if_fail(GAIL_IS_ARROW(obj), NULL); - - arrow = GAIL_ARROW (obj); - - return arrow->image_description; -} - -static gboolean -gail_arrow_set_image_description (AtkImage *obj, - const gchar *description) -{ - GailArrow* arrow; - - g_return_val_if_fail(GAIL_IS_ARROW(obj), FALSE); - - arrow = GAIL_ARROW (obj); - g_free (arrow->image_description); - - arrow->image_description = g_strdup (description); - - return TRUE; - -} - -/* - * static void - * gail_arrow_get_image_size (AtkImage *obj, - * gint *height, - * gint *width) - * - * We dont implement this function for GailArrow as gtk hardcodes the size - * of the arrow to be 7x5 and it is not possible to query this. - */ - -static void -gail_arrow_finalize (GObject *object) -{ - GailArrow *arrow = GAIL_ARROW (object); - - g_free (arrow->image_description); - G_OBJECT_CLASS (gail_arrow_parent_class)->finalize (object); -} diff --git a/gtk/a11y/gailarrow.h b/gtk/a11y/gailarrow.h deleted file mode 100644 index e8a8772e66..0000000000 --- a/gtk/a11y/gailarrow.h +++ /dev/null @@ -1,53 +0,0 @@ -/* GAIL - The GNOME Accessibility Implementation Library - * Copyright 2001 Sun Microsystems Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GAIL_ARROW_H__ -#define __GAIL_ARROW_H__ - -#include "gailwidget.h" - -G_BEGIN_DECLS - -#define GAIL_TYPE_ARROW (gail_arrow_get_type ()) -#define GAIL_ARROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_ARROW, GailArrow)) -#define GAIL_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_ARROW, GailArrowClass)) -#define GAIL_IS_ARROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_ARROW)) -#define GAIL_IS_ARROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_ARROW)) -#define GAIL_ARROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_ARROW, GailArrowClass)) - -typedef struct _GailArrow GailArrow; -typedef struct _GailArrowClass GailArrowClass; - -struct _GailArrow -{ - GailWidget parent; - - gchar* image_description; -}; - -GType gail_arrow_get_type (void); - -struct _GailArrowClass -{ - GailWidgetClass parent_class; -}; - -G_END_DECLS - -#endif /* __GAIL_ARROW_H__ */ diff --git a/gtk/a11y/gtkarrowaccessible.c b/gtk/a11y/gtkarrowaccessible.c new file mode 100644 index 0000000000..78f157fe66 --- /dev/null +++ b/gtk/a11y/gtkarrowaccessible.c @@ -0,0 +1,93 @@ +/* GAIL - The GNOME Accessibility Implementation Library + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include +#include "gtkarrowaccessible.h" + + +static void atk_image_interface_init (AtkImageIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtkArrowAccessible, gtk_arrow_accessible, GAIL_TYPE_WIDGET, + G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)) + +static void +gtk_arrow_accessible_initialize (AtkObject *accessible, + gpointer data) +{ + ATK_OBJECT_CLASS (gtk_arrow_accessible_parent_class)->initialize (accessible, data); + + accessible->role = ATK_ROLE_ICON; +} + +static void +gtk_arrow_accessible_finalize (GObject *object) +{ + GtkArrowAccessible *arrow = GTK_ARROW_ACCESSIBLE (object); + + g_free (arrow->image_description); + + G_OBJECT_CLASS (gtk_arrow_accessible_parent_class)->finalize (object); +} + +static void +gtk_arrow_accessible_class_init (GtkArrowAccessibleClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); + + atk_object_class->initialize = gtk_arrow_accessible_initialize; + + gobject_class->finalize = gtk_arrow_accessible_finalize; +} + +static void +gtk_arrow_accessible_init (GtkArrowAccessible *arrow) +{ + arrow->image_description = NULL; +} + +static const gchar * +gtk_arrow_accessible_get_image_description (AtkImage *obj) +{ + GtkArrowAccessible *arrow = GTK_ARROW_ACCESSIBLE (obj); + + return arrow->image_description; +} + +static gboolean +gtk_arrow_accessible_set_image_description (AtkImage *obj, + const gchar *description) +{ + GtkArrowAccessible *arrow = GTK_ARROW_ACCESSIBLE (obj); + + g_free (arrow->image_description); + arrow->image_description = g_strdup (description); + + return TRUE; + +} + +static void +atk_image_interface_init (AtkImageIface *iface) +{ + iface->get_image_description = gtk_arrow_accessible_get_image_description; + iface->set_image_description = gtk_arrow_accessible_set_image_description; +} diff --git a/gtk/a11y/gtkarrowaccessible.h b/gtk/a11y/gtkarrowaccessible.h new file mode 100644 index 0000000000..ee68c0b83b --- /dev/null +++ b/gtk/a11y/gtkarrowaccessible.h @@ -0,0 +1,53 @@ +/* GAIL - The GNOME Accessibility Implementation Library + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GTK_ARROW_ACCESSIBLE_H__ +#define __GTK_ARROW_ACCESSIBLE_H__ + +#include "gailwidget.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_ARROW_ACCESSIBLE (gtk_arrow_accessible_get_type ()) +#define GTK_ARROW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ARROW_ACCESSIBLE, GtkArrowAccessible)) +#define GTK_ARROW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ARROW_ACCESSIBLE, GtkArrowAccessibleClass)) +#define GTK_IS_ARROW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ARROW_ACCESSIBLE)) +#define GTK_IS_ARROW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ARROW_ACCESSIBLE)) +#define GTK_ARROW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ARROW_ACCESSIBLE, GtkArrowAccessibleClass)) + +typedef struct _GtkArrowAccessible GtkArrowAccessible; +typedef struct _GtkArrowAccessibleClass GtkArrowAccessibleClass; + +struct _GtkArrowAccessible +{ + GailWidget parent; + + gchar *image_description; +}; + +struct _GtkArrowAccessibleClass +{ + GailWidgetClass parent_class; +}; + +GType gtk_arrow_accessible_get_type (void); + +G_END_DECLS + +#endif /* __GTK_ARROW_ACCESSIBLE_H__ */ diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index b8744e70ba..0df37bebc7 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -52,6 +52,8 @@ #include "gtkprivate.h" #include "gtkintl.h" +#include "a11y/gtkarrowaccessible.h" + #define MIN_ARROW_SIZE 15 struct _GtkArrowPrivate @@ -130,6 +132,8 @@ gtk_arrow_class_init (GtkArrowClass *class) GTK_PARAM_READABLE)); g_type_class_add_private (class, sizeof (GtkArrowPrivate)); + + gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ARROW_ACCESSIBLE); } static void -- 2.30.2